﻿using BJoin.Application.WebApi.Validation;
using BJoin.MicroSVC.Sample.DataContract.Dtos;
using BJoin.MicroSVC.Sample.DataContract.ExtObjects;
using FluentValidation;
using System.Collections.Generic;

namespace BJoin.MicroSVC.Sample.Webapi.ParamValidations
{
    public partial class FileExtValidation: AbstractValidator<FileExtObject>
    {
        public FileExtValidation()
        {
            ExFileExtValidation();
        }
        partial void ExFileExtValidation();
    }
    public partial class FileAddDtoValidation : AbstractValidator<FileAddDto>
    {
        public FileAddDtoValidation()
        {
            ExFileAddDtoValidation();
            RuleFor(x => x.Ext).SetValidator(new FileExtValidation());
            #region Enum Property
            //RuleFor(x => x.Status).NotEmpty().IsInEnum().WithMessage(EnumHelper.GetEnumDescription<EnumMessage>(EnumMessage.NotEnumRange));
            #endregion
            #region include base/navigate property class validation
            //Include(new BaseDtoValidation());
            #endregion
            #region Special rule
            //RuleFor(x => x).Must(x => int.Parse(x.StartReportYear.ToString() + x.StartReportPeriod.ToString().PadLeft(2, '0')) <= int.Parse(x.EndReportYear.ToString() + x.EndReportPeriod.ToString().PadLeft(2, '0')))
            //    .When(f => f.StartReportYear.HasValue && f.StartReportPeriod.HasValue && f.EndReportYear.HasValue && f.EndReportPeriod.HasValue).WithMessage(DASConst.ReportRangeInvalid);
            #endregion
            #region method rule
            //RuleFor(x => x).Must(CanNotAllEmpty).WithMessage("method rule fail");
            //bool CanNotAllEmpty(FileAddDto addDto)
            //{
            //    bool result = false;
            //    if (addDto.TagIds != null)
            //        result = true;
            //    return result;
            //}
            #endregion
        }
        partial void ExFileAddDtoValidation();
    }    
    public partial class FileAddManyDtoValidation : AbstractValidator<IList<FileAddDto>>
    {
        public FileAddManyDtoValidation()
        {
            RuleForEach(x => x).SetValidator(new FileAddDtoValidation());
            ExFileAddManyDtoValidation();
        }
        partial void ExFileAddManyDtoValidation();
    }
    public partial class FileUpdateDtoValidation : AbstractValidator<FileUpdateDto>
    {
        public FileUpdateDtoValidation()
        {
            ExFileUpdateDtoValidation();
        }
        partial void ExFileUpdateDtoValidation();
    }
    public partial class FileFilterValidation : AbstractValidator<FileFilter>
    {
        public FileFilterValidation()
        {
            ExFileFilterValidation();
            RuleFor(x => x.OrderBy).SetValidator(new SortDtoValidation<FileDto>());
        }
        partial void ExFileFilterValidation();
    }
}
